﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BSCMFF.Core.MembershipDataProvider;

namespace BSCMFF.Core.DataAccessLayer
{
    public partial class User
    {
        private string fullname;
        public string Fullname
        {
            get
            {
                {
                    if (fullname == null)
                    {
                        fullname = this.Firstname + " " + this.Lastname;
                        //return 
                    }
                    return fullname;
                }
                //else
                //{
                //    return this.Login;
                //}
            }
        }

        public int CurrentEvaluationID
        {
            get
            {
                if (this.Evaluation_Evaluator_Employee.Count != 0)
                {
                    return this.Evaluation_Evaluator_Employee.First().ID;
                }
                else
                {
                    return 0;
                }
            }
        }

        public Evaluation_Evaluator_Employee CurrentEEE
        {
            get
            {
                if (this.Evaluation_Evaluator_Employee.Count != 0)
                {
                    return this.Evaluation_Evaluator_Employee.First();
                }
                else
                {
                    return null;
                }
            }
        }

        public int TotalPKPIsWeight
        {
            get
            {
                //if(
                BSCEntities context = new BSCEntities();

                List<int> total = (from pkpis in context.Personal_KPI
                                   where pkpis.User_FK == this.ID
                                   select pkpis.Weight).ToList();

                if (total == null)
                {
                    return 0;
                }
                else
                {
                    return total.Sum();
                }
            }
            //set
            //{

            //}
        }

    }
}
